const path = require("path");
const fse=require("fs-extra")

class IdePort {
	constructor() {}
	readIdePort() {
		const localAppPath = process.env.LOCALAPPDATA;
		const idePath = path.join(
			localAppPath,
			"/微信web开发者工具/User Data/Default/.ide",
		);
		return fse.readFileSync(idePath,{encoding:'utf-8'});
	}
	initIdePort() {
		window.$PORT = this.readIdePort();
	}
	refreshIdePort() {
		this.initIdePort();
	}
	updateIdePort(port) {
		window.$PORT = port;
	}
	getIdePort() {
		return window.$PORT;
	}
}

module.exports = new IdePort();
